/**
 * 
 */
package bookshop.service.impl;

import java.util.List;

import bookshop.dao.CustomerDao;
import bookshop.dao.DaoFactory;
import bookshop.domain.Customer;
import bookshop.service.CustomerService;
import bookshop.service.helper.CustomerQueryHelper;
import bookshop.utils.Page;

/**
 * @author Administrator
 *
 */
public class CustomerServiceImpl implements CustomerService {

	
	public void newCustomer(Customer customer) {
		
		CustomerDao customerDao=(CustomerDao)DaoFactory.getDao("customerDao");
		customerDao.addCustomer(customer);
	}

	
	public Customer getCustomerById(String customerId) {
		CustomerDao customerDao=(CustomerDao)DaoFactory.getDao("customerDao");		
		return customerDao.getCustomerById(customerId);
	}


	public List<Customer> loadall() {
		CustomerDao customerDao=(CustomerDao)DaoFactory.getDao("customerDao");
		return customerDao.loadall();
	}


	public Page loadCustomerByCondition(CustomerQueryHelper helper, Page page) {
		CustomerDao customerDao=(CustomerDao)DaoFactory.getDao("customerDao");
		page.setTotalRecNum(customerDao.countCustomerByCondition(helper));
		page.setPageContent(customerDao.getScopedCustomers(helper, page.getStartIndex(), page.getPageSize()));
		return page;
	}


	
	public void updateCustomer(Customer customer) {
		CustomerDao customerDao=(CustomerDao)DaoFactory.getDao("customerDao");
		customerDao.updateCustomer(customer);
		
	}

}
